package com.glsc.ngateway.oaflow.service.xirtrade.enums;

import com.glsc.ngateway.common.base.exception.PlatformException;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 衡泰交易指令业务同步OA流程配置项账户类型
 *
 * @author xuchang
 */
@Getter
@AllArgsConstructor
public enum XirTradeOaFlowConfigAccountTypeEnum {
    资金账户("资金账户"),
    证券账户("证券账户"),
    账户树_证券账户("账户树_证券账户"),
    ;
    private String code;

    public static XirTradeOaFlowConfigAccountTypeEnum seek(String code) {
        return Arrays.stream(XirTradeOaFlowConfigAccountTypeEnum.values())
                .filter(o -> o.getCode().equals(code))
                .findFirst()
                .orElseThrow(() -> PlatformException.error(String.format("未找到类型:%s", code)));
    }
    public static List<String> all() {
        return Arrays.stream(XirTradeOaFlowConfigAccountTypeEnum.values()).map(XirTradeOaFlowConfigAccountTypeEnum::getCode).collect(Collectors.toList());
    }
}
